package com.iplant.aps.service.mesenum;

import com.iplant.aps.service.po.cfg.CFGItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 领料需求订单类型
 *
 * @author YouWang·Peng
 *  2022-1-6 10:13:30
 */
public enum WMSOrderType {
    /**
     * 默认
     */
    Default(0, "默认"),
    /**
     * 产线领料订单
     */
    LineOrder(100, "产线领料"),
    /**
     * 换料领料订单
     */
    ChangeOrder(101, "换料领料"),
    /**
     * 客供领料
     */
    CustomerLL(110, "客供领料"),
    /**
     * 反冲领料
     */
    RecoilLL(110, "反冲领料"),
    /**
     * 委外拆修入库
     */
    SubcontractingRepairReceipt(200, "委外拆修入库"),
    /**
     * 自修件送修
     */
    SelfRepairInstock(201, "自修件送修"),
    /**
     * 委外产线领料出库
     */
    OutLL(205, "委外领料");

    private final int value;
    private final String lable;

    WMSOrderType(int value, String lable) {
        this.value = value;
        this.lable = lable;
    }

    /**
     * 通过 value 的数值获取枚举实例
     */
    public static WMSOrderType getEnumType(int val) {
        for (WMSOrderType type : WMSOrderType.values()) {
            if (type.getValue() == val) {
                return type;
            }
        }
        return WMSOrderType.Default;
    }

    public static List<CFGItem> getEnumList() {
        List<CFGItem> wItemList = new ArrayList<CFGItem>();

        for (WMSOrderType type : WMSOrderType.values()) {
            CFGItem wItem = new CFGItem();
            wItem.ID = type.getValue();
            wItem.ItemName = type.getLable();
            wItem.ItemText = type.getLable();
            wItemList.add(wItem);
        }
        return wItemList;
    }

    public int getValue() {
        return value;
    }

    public String getLable() {
        return lable;
    }
}
